#include <iostream>
using namespace std;
string result[1001];
int num=0;

void handle(int k);
int main()
{
	int t;
	while(cin>>t){
		for(int i=0;i<t;i++){
			int m;
			cin>>m;
			handle(m);
		}
		for(int j=0;j<t;j++){
			cout<<result[j]<<endl;
		}
		num=0;
	}
}

void handle(int k)
{
	int a[11];
	int jishu=0;
	while(k>0){
		a[jishu]=k%10;
		k/=10;
		jishu++;
	}
	string temp;
	int position=0;
	while(position<jishu){
		switch(a[position]){
			case 0:
				temp=temp+'O';
				position++;
				break;
			case 1:
				temp=temp+'O';
				position++;
				break;
			case 2:
				temp=temp+'T';
				position++;
				break;
			case 3:
				temp=temp+'T';
				position++;
				break;
			case 4:
				temp=temp+'F';
				position++;
				break;
			case 5:
				temp=temp+'F';
				position++;
				break;
			case 6:
				temp=temp+'S';
				position++;
				break;
			case 7:
				temp=temp+'S';
				position++;
				break;
			case 8:
				temp=temp+'E';
				position++;
				break;
			case 9:
				temp=temp+'N';
				position++;
				break;
		}
	}
	result[num]=temp;
	num++;
}
